package com.snail.auth.entity;

import com.common.entity.IdEntity;
import lombok.Data;

import javax.persistence.*;
import java.sql.Date;
import java.util.List;

@Data
@Entity
@Table(name = "auth_user")
public class AuthUser extends IdEntity {
    private static final long serialVersionUID = 1L;
    @Column(length = 30)
    private String name;//账号昵称
    @Column(length = 20)
    private String loginName;//登录账号
    @Column(length = 32)
    private String password;
    @Column(length = 12)
    private String phone;
    @Column(length = 20)
    private String duty;//职务
    private Integer isLeader;

    private Integer accountState;//账号状态 0-正常；1-删除；2-停用；3-锁定；4-需改密码；
    private Date expireDate;//过期时间
    private Integer isAccountNonExpired;//是否过有效期
    private Integer isAccountNonLocked;//是否被锁定
    private Integer isEnabled;//是否可用

    @ManyToOne(fetch = FetchType.EAGER)
    @JoinColumn(name = "org_id")
    private AuthOrg org;

    @ManyToMany(fetch = FetchType.EAGER, cascade = {CascadeType.ALL})
    @JoinTable(name = "auth_user_role",
            joinColumns = {@JoinColumn(name = "user_id")},
            inverseJoinColumns = {@JoinColumn(name = "role_id")})
    private List<AuthRole> roles;// 一个用户具有多个角色

    @Transient
    private String salt;//加密密码的盐
    @Column(columnDefinition = "int default 0")
    private Integer flag;

}